package mm.chenchen.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.Map;


/**
 * 分页工具类
 */
public class PageUtils {
    private PageUtils() {

    }

    public static Page<Map> getPage(PageParam param) {
        Integer page = param.getCurrentPage();
        Integer rows = param.getPageSize();
        Integer currentPage = page == null ? 1 : page;
        Integer pageSize = rows == null ? 10 : rows;
        return new Page<Map>(currentPage, pageSize);
    }

    public static Page<Map> getPage(Map param) {
        Integer page = (Integer) param.get("page");
        Integer rows = (Integer) param.get("rows");
        Integer currentPage = page == null ? 1 : page;
        Integer pageSize = rows == null ? 10 : rows;
        return new Page<Map>(currentPage, pageSize);
    }
}
